<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
    <title>添加供应商</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<link rel="stylesheet" href="admin/css/common.css" type="text/css" />
	<link rel="stylesheet" href="admin/css/provider.css" type="text/css" />
	<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
	<link rel="stylesheet" href="./kindeditor/themes/default/default.css" />
	<link rel="stylesheet" href="./kindeditor/plugins/code/prettify.css" />
	<script charset="utf-8" src="./kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="./kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="./kindeditor/plugins/code/prettify.js"></script>
	
	<script type="text/javascript">
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="stone.description"]', {
				cssPath : 'kindeditor/plugins/code/prettify.css',
				uploadJson : 'kindeditor/jsp/upload_json.jsp',
				fileManagerJson : 'kindeditor/jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['providerForm'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['providerForm'].submit();
					});
				}
			});
			prettyPrint();
		});
		
	</script>
	<script  type="text/javascript">
	function setDPhoto(e,id){
		 $("#photoList>li").each(function(){
			    $(this).removeClass("select").addClass("unselect");
			});
		e.parentNode.className="select";
		var photoUrlId = "photoUrl_"+id;
		var photoUrl = document.getElementById(photoUrlId).value;
		var tipId = "tip_"+id;
		document.getElementById(tipId).innerHTML = "正在设置默认图片...";
		var params = {
				stoneId : $("#stoneId").val(),
				photoUrl:photoUrl,
				photoId:id
			};
		jQuery.post("adminj/setDefaultPhoto.action", params,
				callbacksetDPhoto, "json");
	}
	function callbacksetDPhoto(value){
		var tipId = "tip_"+value.photoId;
		document.getElementById(tipId).innerHTML = "设置成功";
		}
	</script>
	<script  type="text/javascript">
	function setPhotoDesc(id){
		var textId = "text_"+id;
		var text = document.getElementById(textId).value;
		var tipId = "tip_"+id;
		document.getElementById(tipId).innerHTML = "正在保存...";
		var params = {
				photoDesc : text,
				photoId:id
			};
		jQuery.post("adminj/savePhotoDesc.action", params,
				callbacksavePhotoDesc, "json");
	}
	function callbacksavePhotoDesc(value){
		var tipId = "tip_"+value.photoId;
		document.getElementById(tipId).innerHTML = "保存成功";
		}
	</script>
	<style>
		ul.photoList li{display:block;float:left;}
		ul.photoList li.unselect{width:120px;height:210px;overflow:hidden;padding:5px;margin-right:5px;}
		ul.photoList li.select{width:120px;height:120px;border:5px solid #CCCCCC;padding:0}
		ul.photoList li textarea{display:block;width:120px;height:50px;margin-top:10px;}
		ul.photoList li div{display:block;width:120px;height:20px;line-height:20px;position:relative;overflow:hidden;}
		ul.photoList li div a{display:block;width:40px; text-align:center;float:right;height:20px;line-height:20px;}
		ul.photoList li div span{display:block;width:80px;height:20px;float:left;line-height:20px;}
	</style>
  </head>
  <body>
  	<div id="provider_zone">
		  <table width="99%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_style">
		    <tr>
		      	<td width="18%" class="left_title_1">石材名字</td>
			      <td width="82%" style="line-height: 30px; width: 305px; color:#73938E; font-size: 10pt;">
						${stone.chineseName }
			      </td>
		    </tr>
		    <tr>
		    	<td>设置石材默认图片</td>
		    	<td>
		    		<ul class="photoList" id="photoList">
		    		<c:forEach items="${photos }" var="item" > 
		    			<c:if test="${item.defaultPhoto == 1}">
						    <li id="photo_${item.id }" class="select">
			    				<img src="upload/stone/120/${item.url }"  onclick="setDPhoto(this,${item.id })"/>
			    				<input type="hidden" id="photoUrl_${item.id }" value="${item.url }"/>
				    			<textarea id="text_${item.id }" type="text" value="" name="photo.description"></textarea>
				    			<div>
				    			<span id="tip_${item.id }"></span><a class="button" onclick="setPhotoDesc(${item.id })">确定</a>
				    			</div>
			    			</li>
			    		</c:if>
		    			<c:if test="${item.defaultPhoto != 1}">
		    				 <li id="photo_${item.id }" class="unselect">
			    				<img src="upload/stone/120/${item.url }" onclick="setDPhoto(this,${item.id })"/>
			    				<input type="hidden" id="photoUrl_${item.id }" value="${item.url }"/>
				    			<textarea id="text_${item.id }" type="text" value=""></textarea>
				    			<div>
				    			<span style="color:green;font-size:12px;" id="tip_${item.id }"></span><a class="button" onclick="setPhotoDesc(${item.id })">确定</a>
				    			</div>
			    			</li>
		    			</c:if>
					</c:forEach>			
		    		</ul>
		    		<input type="hidden" value="0" id="defaultPhotoId" name="defaultPhotoId"/>
		    	</td>
		    </tr>
		    </table>
		     <form action="admin/saveDescription.action" name="providerForm" method="post" onsubmit="return check();">
		    <table width="99%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_style">
		    
		 
			    <tr>
			    	<td>石头概要介绍</td>
			    	<td>
			    		<textarea name="shortDesc" style="width:500px;height:100px;"></textarea>
			    	</td>
			    </tr>
			     <tr>
			      	<td class="left_title_2" >
			      	</td>
			      	<td>
			      		<span>
								&nbsp;&nbsp;石材的详细介绍<br />
						</span>	      		
			      	</td>
			    </tr>
			    <tr>
			      	<td colspan="2">
			      		<textarea id="description" name="stone.description" style="width:99%;height:500px;visibility:hidden;"></textarea>
			      	</td>
			    </tr>
			    <tr>
			    	<td colspan="2"  class="left_title_2">
						<input type="submit" class="input-submit" value="保存，下一步">(提交快捷键: Ctrl + Enter)
					</td>
			    </tr>
			    <input name="stoneId" id="stoneId" type="hidden" value="${stone.id }"/>
	  		
		  </table>
		  </form>
	</div>
  </body>
</html>
